package com.hardy.Thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * Author: fuxh3@lenovo.com
 * Date: Created in 2018/1/8 0008
 */
public class FutureTaskSample {
    static FutureTask<String> future = new FutureTask<String>(new Callable<String>() {
        @Override public String call() throws Exception {
            return getPageContent();
        }
    });
    public static String getPageContent(){
        return "testPageContent and provide that the operation is a time exhausted thing,";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        new Thread(future).start();
        System.out.println(future.get());
        System.out.println(doDownThing());
    }
    public static String doDownThing(){
        return "Do Own Thing";
    }
}
